package com.program.cloudmanagesystem.hotel.config;
import com.program.cloudmanagesystem.hotel.service.HotelService;
import com.program.cloudmanagesystem.hotel.domain.Hotel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Random;

@Component
public class Schedule {
    @Autowired
    private HotelService hotelService;
    Hotel hotel = new Hotel();

    int a = 1;
    String c = "01";
    //@Scheduled(fixedRate = 5000)
    public void test(){
        Random random = new Random();
        Random random1 = new Random();
        Random random2 = new Random();
        hotel.setId(c);
        hotel.setCapacity(String.valueOf(random1.nextInt(201)));
        hotel.setCheck(String.valueOf(random2.nextInt(51)));
        hotel.setInformation("a");
        hotel.setMaxcapacity("200");//客流量
        hotel.setMaxcheck("50");//入住
        hotel.setMaxparking("100");

        hotel.setParking(String.valueOf(random.nextInt(11)));
        System.out.println(hotel.getParking());
        hotelService.updateNow(hotel);
        System.out.println(a);
        a++;
    }
}
